package constant;

/**
 * Created by chenkuo on 2018/1/16.
 */
public enum  CityId {
    beijing("北京市", 1101),
    shanghai("上海市",3301),;


    private String cityName;
    private Integer cityCode;

    CityId(String cityName, Integer cityCode) {
        this.cityName = cityName;
        this.cityCode = cityCode;
    }


    public static Integer getCityCodeByName(String cityName) {
        CityId[] values = CityId.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].cityName.equals(cityName)) {
                return values[i].cityCode;
            }
        }
        return null;
    }
}
